<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace suifeng\builder\form\validator;

use suifeng\builder\form\Validator;

class IpAllow extends Validator
{
    /**
     * IP地址数组。
     *
     * @var array
     */
    public $ip_list = array();

    /**
     * 错误信息。
     *
     * @var string
     */
    public $message = '客户端IP不允许。';

    /**
     * 验证方法。
     */
    protected function _validate_core()
    {
        if (in_array(get_client_ip(), $this->ip_list)) {
            return;
        }

        $this->errors[] = $this->_format_message(null);
    }
}
